package com.common.frame.utils;

import android.text.TextUtils;

import com.common.frame.R;

/**
 *
 * DeviceTypeEnum
 *
 * /// <summary>
 *         /// 未知设备
 *         /// </summary>
 *         UnKnow = 0,
 *
 *         /// <summary>
 *         /// Android 手机
 *         /// </summary>
 *         AndroidPhone = 1,
 *
 *         /// <summary>
 *         /// 安全帽
 *         /// </summary>
 *         Helmet = 2,
 *
 *         /// <summary>
 *         /// 车载Gps设备
 *         /// </summary>
 *         VehicleGps = 3,
 *
 *         /// <summary>
 *         /// 手持机
 *         /// </summary>
 *         Handheld = 4,
 *
 *         /// <summary>
 *         /// 平板
 *         /// </summary>
 *         Pad = 5,
 *
 *         /// <summary>
 *         /// 无人机
 *         /// </summary>
 *         Drone = 6,
 *
 *         /// <summary>
 *         /// 工牌
 *         /// </summary>
 *         Badge = 7,
 *
 *         /// <summary>
 *         /// 防爆手机
 *         /// </summary>
 *         ExplosionProofMobilePhone = 8
 *
 * @author: sunxy11
 * @email: sunxy11@iflytek.com
 * @date: 2022/4/16
 */
public enum DeviceTypeEnum {

    UNKNOW(0, "unknow", "未知设备", R.mipmap.device_card),
    PHONE(1, "phone", "普通手机", R.mipmap.device_phone),
    HAT(2, "hat", "智能安全帽", R.mipmap.device_hat),
    HOLD(8, "hold", "防爆手持", R.mipmap.device_phone),
    CARD(7, "card", "定位工牌", R.mipmap.device_card),
    ;

    public int type;
    public String name;
    public String desc;
    public int iconResId;

    private DeviceTypeEnum(int type, String name, String desc, int iconResId) {
        this.type = type;
        this.name = name;
        this.desc = desc;
        this.iconResId = iconResId;
    }

    public static DeviceTypeEnum getDeviceType(int type) {
        for (DeviceTypeEnum value : DeviceTypeEnum.values()) {
            if (value.type == type) {
                return value;
            }
        }
        return DeviceTypeEnum.UNKNOW;
    }

    public static DeviceTypeEnum getDeviceType(String nameOrDesc) {
        for (DeviceTypeEnum value : DeviceTypeEnum.values()) {
            if (TextUtils.equals(nameOrDesc, value.name)
                    || TextUtils.equals(nameOrDesc, value.desc)) {
                return value;
            }
        }
        return DeviceTypeEnum.UNKNOW;
    }
}
